//-----------------------------------------------------------------------------
// Bend2D - Physics Engine
// Roberto Bender <beto.bender@gmail.com>
// Description: 
// Date: 10/03/2010
//-----------------------------------------------------------------------------
#ifndef DURABLE_H
#define DURABLE_H

#include "durableresetter.h"

#include <list>
using namespace std;

namespace bend2d
{
    class Durable 
    {
    public:
        typedef list<Durable*> DurableList;
        DurableList::iterator& GetDurableIterator();
        
        Durable();
        void SetIterationSense(bool sensitive, unsigned int iterationsToLive);
        void SetTimeSense(bool sensitive, double timeToLive);
        bool IsIterationSensitive() const;
        bool IsTimeSensitive() const;
        unsigned int GetIterationsToLive() const;
        double GetTimeToLive() const;
        void Reset();
        bool Live(double timeSinceLastFrame, unsigned int iterations = 1);
        void SetDurableResetter(DurableResetter * ptr);
        DurableResetter * GetDurableResetter() const;
    private:
        DurableList::iterator m_Iterator;
        DurableResetter *m_Resetter;
        unsigned int m_IterationsToLive;
        unsigned int m_IterationsLiving;
        double m_TimeToLive;
        double m_TimeLiving;
        bool m_IterationSensitive;
        bool m_TimeSensitive;
    };
}

#endif
